package mess;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_784 {
    public static void main(String[] args) {
        System.out.println(letterCasePermutation("hsadhjaasddash"));
    }
    private static List<String> letterCasePermutation(String s) {
        List<String> list = new ArrayList<>();
        list.add("");
        int len = s.length();
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (c >= 65 && c <= 90){
                int num = list.size();
                list.addAll(list);
                for (int k = 0; k < num; k++) {
                    list.set(k, list.get(k) + c);
                }
                for (int k = num; k < 2 * num; k++) {
                    list.set(k, list.get(k) + (char) (c + 32));
                }
                continue;
            }
            if (c >= 97 && c <= 122){
                int num = list.size();
                list.addAll(list);
                for (int k = 0; k < num; k++) {
                    list.set(k, list.get(k) + c);
                }
                for (int k = num; k < 2 * num; k++) {
                    list.set(k, list.get(k) + (char) (c - 32));
                }
                continue;
            }
            for (int j = 0; j < list.size(); j++) {
                list.set(j, list.get(j) + c);
            }
        }
        return list;
    }
}
